from Tkinter import Tk, Menu, Frame, Button, Label, Text
from Tkconstants import LEFT, TOP, X, W, BOTTOM, SUNKEN, INSERT



class Shell():

    def __init__(self):        
        root = Tk()
        text = Text(root)
        text.tag_config("a", foreground="blue", underline=1)
        text.config(cursor="arrow")
        
        
        text.insert(INSERT, "click here!", "a")
        text.pack()
          
        self.create_menu(root)        
        self.create_toolbar(root)        
        self.create_status_bar(root)
             
        root.mainloop()
        

    def create_status_bar(self, root):
        self.status = Label(root, text="", bd=1, relief=SUNKEN, anchor=W)
        self.status.pack(side=BOTTOM, fill=X)
        
    def create_toolbar(self, root):
        # create a toolbar
        toolbar = Frame(root)
        b = Button(toolbar, text="new", width=6, command=self.callback("new"))
        b.pack(side=LEFT, padx=2, pady=2)
        b = Button(toolbar, text="open", width=6, command=self.callback("open"))
        b.pack(side=LEFT, padx=2, pady=2)
        toolbar.pack(side=TOP, fill=X)

    def create_menu(self, root):
        # create a menu
        menu = Menu(root)
        root.config(menu=menu)
        filemenu = Menu(menu)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="New", command=self.callback("New"))
        filemenu.add_command(label="Open...", command=self.callback("Open..."))
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.callback("Exit"))
        helpmenu = Menu(menu)
        menu.add_cascade(label="Help", menu=helpmenu)
        helpmenu.add_command(label="About...", command=self.callback("About..."))

    
    def callback(self, __text):
        def inner_callback():
            self.print_status( __text)
        return inner_callback
        
    def print_status(self, __text):        
        self.status.config(text=__text)
        self.status.update_idletasks()
        
Shell()
